var loginCtrl = myApp.controller('loginCtrl', ['$scope', function($scope) {
	/**
	 * 初始化方法
	 * @return {[type]}
	 */
	$scope.userName = "";
	$scope.pwd = "";
	function init() {
		$(document).ready(function() {
			
		});
	}
	init();

	/**
	 * 登录
	 * @return {[type]} [description]
	 */
	$scope.login = function() {
		if($scope.userName == undefined || $scope.userName == "") {
			alert("请输入用户名");
			return;
		}
		if($scope.pwd == undefined || $scope.pwd == "") {
			alert("请输入密码");
			return;
		}
		var data = {
			userName: $scope.userName,
			pwd: $scope.pwd
		}
		commonSrv.login(data, function(result) {
			if(result.status == 0) {
				var user = result.data;
				user = JSON.stringify(user);
				// 登录成功
				Tools.cookie.set("user", user, 2);
				window.location.href = './main.html';
			}
		}, function(result) {
			if(result.status == 1) {
				alert('用户名不存在');
			} else if(result.status == 2) {
				alert('密码错误');
			}
		}, function () {
			$scope.$apply();
		});
	};
}]);